﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Settings;

namespace djs_mp3_manager
{
    public partial class MainWindow : Form
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void MainWindow_Load(object sender, EventArgs e)
        {

            #region Static modules init
            Setting.Init();
            LanguageManager.Init();
            #endregion       

            #region LanguageAndSettingsInit
            LanguageManager.SetLocalization(this);
            #endregion

            #region TabControlInit
            tabControl.ItemSize = new Size((tabControl.Size.Width / tabControl.TabPages.Count) - 2, tabControl.ItemSize.Height);
            #endregion
        
            #region Component init
            UpdateGenreTree();
            #endregion
        }

        private void možnostiToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Nastroje.Moznosti moznosti = new Nastroje.Moznosti();
            moznosti.OnSaveEvent += new Nastroje.Moznosti.OnSaveDelegate(OnSave_event);
            moznosti.ShowDialog();
            moznosti.Dispose();
        }

        private void oAplikaciToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Napoveda.AboutBox aboutbox = new Napoveda.AboutBox();
            aboutbox.ShowDialog();
            aboutbox.Dispose();
        }

        private void MainWindow_SizeChanged(object sender, EventArgs e)
        {
            tabControl.ItemSize = new Size((tabControl.Size.Width / tabControl.TabPages.Count) - 2, tabControl.ItemSize.Height);
        }

        protected void OnSave_event()
        {
            #region Update GenreTree
            UpdateGenreTree();
            #endregion
            
        }

        private void UpdateGenreTree()
        {
            genreTree.Nodes[0].Nodes.Clear();
            genreTree.Nodes[0].Nodes.AddRange(Setting.Genres.GetTreeNodeArrayFromTreeNodeCollection(Setting.Genres.GenreList));
            genreTree.Nodes[0].Expand();
        }
    }
}
